<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
    <button @click="fn">操作</button>
    <one ref="one"></one>
</div>
</body>
<script>
    // ref如果作为组件的属性，那么通过this.$refs.属性名可以获取到该组件的实例
	new Vue({
		el:"#root",
        components:{
			One:{
				data(){
					return {
						num:100
                    }
                },
                template:(`
                    <button @click="num++">{{num}}</button>
                `)
            }
        },
        mounted(){
			console.log(this.$refs.one);
        },
        methods:{
			fn(){
				this.$refs.one.num+=2;
            }
        }
	})
</script>
</html>